<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>初见VUE</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <button :style="chooseBtn == '按钮1'?activeStyle:''" @click="clickHandler">按钮1</button>
    <button :style="chooseBtn == '按钮2'?activeStyle:''" @click="clickHandler">按钮2</button>
    <button :style="chooseBtn == '按钮3'?activeStyle:''" @click="clickHandler">按钮3</button>
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        activeStyle: {
          backgroundColor: 'teal',
          color: 'white'
        },
        chooseBtn: ''
      },
      methods: {
        // 点击处理函数
        clickHandler(event) {
          // console.log(event.target.innerText);
          this.chooseBtn = event.target.innerText
        }
      }
    })
  </script>
</body>
</html>